package com.nantong.admin.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * BCrypt密码生成工具
 */
public class BCryptPasswordGenerator {

    /**
     * 生成BCrypt加密后的密码
     */
    public static void main(String[] args) {
        // 默认密码
        String[] passwords = {"123456", "admin123", "password"};
        
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        
        System.out.println("BCrypt密码生成工具");
        System.out.println("===========================================");
        
        for (String password : passwords) {
            String encodedPassword = encoder.encode(password);
            System.out.println("原始密码: " + password);
            System.out.println("加密密码: " + encodedPassword);
            System.out.println("验证结果: " + encoder.matches(password, encodedPassword));
            System.out.println("-------------------------------------------");
        }
        
        // 如果需要加密自定义密码，可以取消下面注释
        // 将自定义密码替换为您需要加密的密码
        String customPassword = "123456";
        String encodedCustomPassword = encoder.encode(customPassword);
        System.out.println("\n自定义密码加密结果:");
        System.out.println("原始密码: " + customPassword);
        System.out.println("加密密码: " + encodedCustomPassword);
        System.out.println("验证结果: " + encoder.matches(customPassword, encodedCustomPassword));
    }
}
